﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using ITManagerProject;

namespace ITManagerProject
{
   public class SetupEveronment: SPFeatureReceiver
    {
       public override void FeatureActivated(SPFeatureReceiverProperties properties)
       {
        
           //Define all list 
           //Khoi tao cac quyen co ban 

           
           //khoi tao list tiepnhan
           using (SPWeb sweb = properties.Feature.Parent as SPWeb)
           {
               var splist = sweb.Lists;
               
              
               if (splist["TiepNhan"] != null)
               {
                   SPFieldCollection collField = splist["TiepNhan"].Fields;

                   //Create Column 
                   collField.Add(Common.Constant.DEPARTMENTNAME, SPFieldType.Text, true);
                   collField.Add(Common.Constant.PROJECTNAME, SPFieldType.Text, true);
                   collField.Add(Common.Constant.RECEVINGBY, SPFieldType.User, true);
                   collField.Add(Common.Constant.RECEVINGDATE, SPFieldType.DateTime, false);
                   collField.Add(Common.Constant.REGESTRYNAME, SPFieldType.Text, true);
                   collField.Add(Common.Constant.STATUS, SPFieldType.Boolean, false);
                   collField.Add(Common.Constant.NUMBERFILEATTACH, SPFieldType.Number, false);
                   collField.Add(Common.Constant.IDCODE, SPFieldType.Text, false);
                   collField.Add(Common.Constant.PROJECTVALUE, SPFieldType.Text, false);
                   collField.Add(Common.Constant.PHONENUMBER, SPFieldType.Text, false);
                   collField.List.Update();
               }
               else
               {
                   splist.Add("TiepNhan", "Tiep nhan ho so", SPListTemplateType.GenericList);
               
               }


               sweb.Update();
           }


           //Khoi tao list thu ly




           //khoi tao list ky duyet


       }

       public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
       {
           /* no op */
       }

       public override void FeatureInstalled(SPFeatureReceiverProperties properties)
       {
           /* no op */
       }
       public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
       {
           /* no op */
       }
    }
}
